<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <template id="my-app">
    <!-- Mustache的基本使用 -->
    <h2>{{message}}</h2>
    <!-- 表达式 -->
    <h2>{{counter * 10}}</h2>
    <h2>{{message.split(" ").reverse().join()}}</h2>
    <!-- 调用函数、使用计算属性 -->
    <h2>{{function1()}}</h2>
    <!-- 三元运算符 -->
    <h2>{{isShow ? "哈哈哈" : ""}}</h2>
    <button @click="toggle">切换</button>
  </template>

  <script src="../js/vue.js"></script>
  <script>
    const App = {
      template: "#my-app",
      data() {
        return {
          message: "Hello World",
          counter: 100,
          isShow: true,
        }
      },
      methods: {
        function1() {
          return this.message.split(" ").reverse().join();
        },
        toggle() {
          this.isShow = !this.isShow;

        }
      },
    };

    Vue.createApp(App).mount("#app");
  </script>
</body>

</html>